package com.github.prontera.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.prontera.domain.SysDict;
import com.github.prontera.persistence.CrudMapper;
import com.github.prontera.persistence.SysDictMapper;
import com.github.prontera.util.Page;

@Service("sysDictService")
public class SysDictService extends CrudServiceImpl<SysDict>{
    
	@Autowired
	private SysDictMapper sysDictMapper;
	
	
	public SysDictService(CrudMapper<SysDict> mapper) {
		super(mapper);
	}
	
	public List<SysDict> find2(SysDict findSysDict) {
		return sysDictMapper.find2(findSysDict);
	}

	public Page<SysDict> findDictList(SysDict tag) {
//		if(tag!=null){
//			tag.setClientId(Long.parseLong("0"));
//		}
		tag.setOrderBy(" type,create_time  asc ");
		long count = sysDictMapper.count(tag);
		if(tag.getPageSize()==null||tag.getPageSize()<2||tag.getPageSize()>100){
			tag.setPageSize(10);
		}
		if(tag.getPageIndex()==null){
			tag.setPageIndex(1);
		}
		Page<SysDict> page = new Page<SysDict>(tag.getPageIndex(),tag.getPageSize());
		page.setData(sysDictMapper.find(tag));
		page.setTotalCount(count);
		return page;
	}
    
}